package javaClassExercise.fanshe;

/**
 * Created by lomo.
 * 通过类对象i调用newInstance()方创建对象
 */
public class TestReflectByNewInstance {
    public static void main(String[] args) throws Exception{
        TestReflectByNewInstance testReflectByNewInstance = TestReflectByNewInstance.class.newInstance();

        //.getClass方法得到testReflectByNewInstance对象的Class类对象(此对象中包含了创建该类的实例对象的所有信息)
        TestReflectByNewInstance testReflectByNewInstance1 = testReflectByNewInstance.getClass().newInstance();

        Class testReflectByNewInstanceClass = Class.forName("TestReflectByNewInstance");
        TestReflectByNewInstance testReflectByNewInstance2 = (TestReflectByNewInstance) testReflectByNewInstanceClass.newInstance();

        System.out.println(testReflectByNewInstance instanceof TestReflectByNewInstance);

    }
}